'''
Author: your name
Date: 2021-11-05 14:51:43
LastEditTime: 2021-11-05 17:01:23
LastEditors: Please set LastEditors
Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
FilePath: /tinyms/tinyms-api/apps/cms/site/model.py
'''
from app import db

class Site(db.Model):
    __tablename__ = 'cms_site'
    site_pk = db.Column(db.Integer,primary_key=True,autoincrement=True)
    site_name =  db.Column(db.String)
    site_domain = db.Column(db.String)
    site_path = db.Column(db.String)
    site_template = db.Column(db.String)
    site_time = db.Column(db.String)
    site_remarks = db.Column(db.String)
    site_state = db.Column(db.String)
    

    '''
    list转化为dict,否则无法转为json输出
    '''
    def to_dict(items):
        dic = []
        for item in items:
            dic.append(
                {
                    'site_pk':item.site_pk,
                    'site_name':item.site_name,
                    'site_domain':item.site_domain,
                    'site_path':item.site_path,
                    'site_template':item.site_template,
                    'site_time':item.site_time,
                    'site_remarks':item.site_remarks,
                    'site_state':item.site_state
                }
            )
        return dic
    